package com.ruoyi.program.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.program.domain.CpsAlipayApplications;
import com.ruoyi.program.service.ICpsAlipayApplicationsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 支付宝第三方应用模板Controller
 * 
 * @author ruoyi
 * @date 2025-04-12
 */
@RestController
@RequestMapping("/program/program")
public class CpsAlipayApplicationsController extends BaseController
{
    @Autowired
    private ICpsAlipayApplicationsService cpsAlipayApplicationsService;

    /**
     * 查询支付宝第三方应用模板列表
     */
    @PreAuthorize("@ss.hasPermi('program:program:list')")
    @GetMapping("/list")
    public TableDataInfo list(CpsAlipayApplications cpsAlipayApplications)
    {
        startPage();
        List<CpsAlipayApplications> list = cpsAlipayApplicationsService.selectCpsAlipayApplicationsList(cpsAlipayApplications);
        return getDataTable(list);
    }

    /**
     * 导出支付宝第三方应用模板列表
     */
    @PreAuthorize("@ss.hasPermi('program:program:export')")
    @Log(title = "支付宝第三方应用模板", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CpsAlipayApplications cpsAlipayApplications)
    {
        List<CpsAlipayApplications> list = cpsAlipayApplicationsService.selectCpsAlipayApplicationsList(cpsAlipayApplications);
        ExcelUtil<CpsAlipayApplications> util = new ExcelUtil<CpsAlipayApplications>(CpsAlipayApplications.class);
        util.exportExcel(response, list, "支付宝第三方应用模板数据");
    }

    /**
     * 获取支付宝第三方应用模板详细信息
     */
    @PreAuthorize("@ss.hasPermi('program:program:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cpsAlipayApplicationsService.selectCpsAlipayApplicationsById(id));
    }

    /**
     * 新增支付宝第三方应用模板
     */
    @PreAuthorize("@ss.hasPermi('program:program:add')")
    @Log(title = "支付宝第三方应用模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CpsAlipayApplications cpsAlipayApplications)
    {
        return toAjax(cpsAlipayApplicationsService.insertCpsAlipayApplications(cpsAlipayApplications));
    }

    /**
     * 修改支付宝第三方应用模板
     */
    @PreAuthorize("@ss.hasPermi('program:program:edit')")
    @Log(title = "支付宝第三方应用模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CpsAlipayApplications cpsAlipayApplications)
    {
        return toAjax(cpsAlipayApplicationsService.updateCpsAlipayApplications(cpsAlipayApplications));
    }

    /**
     * 删除支付宝第三方应用模板
     */
    @PreAuthorize("@ss.hasPermi('program:program:remove')")
    @Log(title = "支付宝第三方应用模板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cpsAlipayApplicationsService.deleteCpsAlipayApplicationsByIds(ids));
    }
}
